﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BASE;

public partial class Admin_resetMatKhau : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Utils.getIntSession("userid") == 0)
        {
            Response.Redirect("/admin/login.aspx");
        }
        //check quyen vao trang

        busMenu busM = new busMenu();
        if (!busM.checkQuyenVaoTrang(Utils.getIntSession("userid"), Constants.ADMIN_SINHVIEN))
        {
            Response.Redirect("/admin/");
        }
        Session["trang"] = Constants.ADMIN_SINHVIEN;
        btn_reset.Visible = false;
        div_tt.Visible = false;
    }
    protected void btn_luu_Click(object sender, EventArgs e)
    {
        busSinhVien busSV = new busSinhVien();
        entSinhVien entSV = new entSinhVien();
        entSV = busSV.getSinhVienByMaSV(txt_msv.Text);
        if (entSV.MaSinhVien != "")
        {
            lb_ten.Text = entSV.Ho + " " + entSV.Ten;
            lb_lop.Text = entSV.MaLop;
            lb_email.Text = entSV.Email;
            lb_dienthoai.Text = entSV.DienThoai;
            btn_luu.Visible = false;
            btn_reset.Visible = true;
            div_tt.Visible = true;
            lb_msv.Text = entSV.MaSinhVien;
            lb_me.Text = "";
            div_me.Visible = false;
        }
        else
        {
            lb_me.Text = "Mã sinh viên không đúng";
        }

    }
    protected void btn_reset_Click(object sender, EventArgs e)
    {
        busSinhVien busSV = new busSinhVien();
        busSV.resetmk(lb_msv.Text);
        lb_me.Text = "Reset thành công";
        div_me.Visible = true;
        btn_luu.Visible = true;
    }
}